package com.oa.modules.approvalsec1.service.impl;

import cn.hutool.core.date.DateUtil;
import org.springframework.stereotype.Service;

import java.util.*;

import com.oa.common.utils.AppUtils;
import com.oa.common.utils.Constant;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.oa.common.utils.PageUtils;
import com.oa.common.utils.Query;

import com.oa.modules.approvalsec1.dao.AdministrativeMattersDao;
import com.oa.modules.approvalsec1.entity.AdministrativeMattersEntity;
import com.oa.modules.approvalsec1.service.AdministrativeMattersService;

/**
 * 
 *
 * @author Hankaicheng
 * @email 3131408121@qq.com
 * @date 2022-08-29 10:09:16
 */
@Service("administrativeMattersService")
public class AdministrativeMattersServiceImpl extends ServiceImpl<AdministrativeMattersDao, AdministrativeMattersEntity> implements AdministrativeMattersService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        params.put("status", Constant.YES_OR_NO.YES.getValue());
        IPage page= AppUtils.getPage(new Query<AdministrativeMattersEntity>(), params);
        return AppUtils.setPage(page, baseMapper.findPage(params), baseMapper.findRecords(page, params));
    }

    @Override
    public List<Map<String, Integer>> matterStateTj() {
        return baseMapper.matterStateTj();
    }

    @Override
    public Map matterDateTj() {
        ArrayList<Object> list = new ArrayList<>();
        for (int i = 0; i < 7; i++) {
            list.add(DateUtil.dayOfMonth(DateUtil.offsetDay(new Date(),-i)));
        }
        Collections.reverse(list);
        List<Integer> count = baseMapper.matterDateTj(list);
        Collections.reverse(count);
        HashMap<Object, Object> result = new HashMap<>();
        result.put("name",list);
        result.put("value",count);
        return result;
    }

    @Override
    public List zwtj() {
        ArrayList list = new ArrayList<>();
        List<Map<String, Integer>> lxtj = baseMapper.lxtj();
        lxtj.forEach(item->{
            item.put("cakeType",0);
        });
        List<Map<String, Integer>> shtj = baseMapper.shtj();
        shtj.forEach(item->{
            item.put("cakeType",1);
        });
        List<Map<String, Integer>> sctj = baseMapper.sctj();
        sctj.forEach(item->{
            item.put("cakeType",2);
        });
        list.add(lxtj);
        list.add(shtj);
        list.add(sctj);
        return list;
    }



}
